"""Minimum time between domain restarts in seconds."""
MINIMUM_RESTART_TIME = 20
+RESTART_IN_PROGRESS = 'xend/restart_in_progress'
+
xc = xen.lowlevel.xc.new()
xroot = XendRoot.instance()
config = self.sxpr()
- if self.readVm('xend/restart_in_progress'):
+ if self.readVm(RESTART_IN_PROGRESS):
log.error('Xend failed during restart of domain %d. '
'Refusing to restart to avoid loops.',
self.domid)
self.destroy()
return
- self.writeVm('xend/restart_in_progress', 'True')
+ self.writeVm(RESTART_IN_PROGRESS, 'True')
now = time.time()
rst = self.readVm('xend/previous_restart_time')
self.preserveForRestart()
else:
self.destroyDomain()
-
+
+ # new_dom's VM will be the same as this domain's VM, except where
+ # the rename flag has instructed us to call preserveForRestart.
+ # In that case, it is important that we remove the
+ # RESTART_IN_PROGRESS node from the new domain, not the old one,
+ # once the new one is available.
+
+ new_dom = None
try:
xd = get_component('xen.xend.XendDomain')
new_dom = xd.domain_create(config)
- try:
- new_dom.unpause()
- except:
- new_dom.destroy()
- raise
+ new_dom.unpause()
+ new_dom.removeVm(RESTART_IN_PROGRESS)
except:
- log.exception('Failed to restart domain %d.', self.domid)
- finally:
- # new_dom's VM will be the same as this domain's VM, except where
- # the rename flag has instructed us to call preserveForRestart.
- # In that case, it is important that we use new_dom.removeVm, not
- # self.removeVm.
- new_dom.removeVm('xend/restart_in_progress')
-
- # self.configure_bootloader()
- # self.exportToDB()
+ if new_dom:
+ new_dom.removeVm(RESTART_IN_PROGRESS)
+ new_dom.destroy()
+ else:
+ self.removeVm(RESTART_IN_PROGRESS)
+ raise
+ except:
+ log.exception('Failed to restart domain %d.', self.domid)
def preserveForRestart(self):